<%@page import="javax.naming.InitialContext"%>
<%@page import="javax.naming.Context"%>
<%@page import="VietDQ.VietDQSessionBeanLocal"%>
<%@page import="Entity.Event"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.text.DateFormat"%>
<%
            if (session.getAttribute("Admin_Session") != null) {
                response.sendRedirect("index.jsp");
            } else {

%>
<%@page import="Entity.Account"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>National Level Paper Presentation</title>
<link href="templatemo_style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="css/calendar-eightysix-v1.1-default.css" media="screen" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/piroBox.1_2.js"></script>
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
</head>
<body>
    <!-----------------------------header--------------------------------------->
<div id="templatemo_header_wrapper">
    <jsp:include page="header.jsp" flush="true"/>

</div>
<!-------------------------------- end header ---------------------------------->

<!--------------------------------- menu ------------------------>
<div id="templatemo_menu_wrapper">
    <div id="templatemo_menu">

        <ul>
            <li><a href="index.jsp" class="current">Home</a></li>
            <li><a href="VietDQServlet?action=UserGetAllEvents">Events</a></li>
<%
    if(session.getAttribute("User_Session")!=null){
        Account ac = (Account)session.getAttribute("User_Session");
%>
            <li><a href="PhuocPHServlet?action=UViewFB&User_Session=<%= ac.getUsername() %>">Feedback</a></li>
<%
            }
%>
            <li><a href="AboutUS.jsp">About Us</a></li>
            <li><a href="VietDQServlet?action=ViewFAQ">FAQ</a></li>
        </ul>

    </div>
</div>
<!---------------------------------end  menu ------------------------>

<!--------------------------------- Content ------------------------>
<div id="templatemo_content_wrapper">

	<div id="templatemo_sidebar">
            <div class="sidebar_box">
<%
                    if(session.getAttribute("User_Session")==null)
                    {

%>
            <h2>Login</h2>
            <form name="f1" action="LoginServlet" method="post">
                <table>
                    <tr>
                    <td><label>Username: </label></td>
                    <td><input type="text" value="" name="txtUsername" id="input_field" /></td>
                    </tr>
                    <tr>
                    <td><label>Password: </label></td>
                    <td><input type="password" value="" name="txtPassword" id="input_field" /></td>
                    </tr>
                    <tr>
                     <td></td>
                     <td align="right"><input type="submit" name="action" value="Sign In" class="Button"/></td>
                    </tr>
                </table>
                 <%

                                   if(session.getAttribute("Invalid")!=null)
                                  {
                                %>
                                <label style="color: red"><%=session.getAttribute("Invalid").toString() %></label>
                                <%

                            }%>
                            <a href="Register.jsp">Sign Up</a>
                <br/>
               <a href="Forgot1.jsp">Forgot Password ?</a>
            </form>
 <%
            }else{
                       Account ac = (Account)session.getAttribute("User_Session");

                      DateFormat df = new SimpleDateFormat("dd/MM/yyyy");
                      String date=df.format(ac.getDateJoin());
%>
                            <h2>Welcome</h2>
                            <form name="f2" action="LoginServlet" method="post">
                    <table align="center">
                        <tr>
<%
        if(ac.getAvatar()==null)
            {
%>
                      <td colspan="2"><img class="avatar" src="images/avatar/avatar.jpg"/></td>
<%
        }else{

%>
                      <td colspan="2"><img class="avatar" src="images/avatar/<%= ac.getAvatar() %>"/></td>
<%
               }
%>
                      </tr>
                    <tr>
                   <%
                        if(ac.getGender().equals("Male"))
                            {
                %>
                    <td><label>
                      <div align="justify">Mr :</div>
                      </label></td>
                    <%
                            }else{
                    %>
                    <td><label>
                      <div align="justify">Ms :</div>
                      </label></td>
                    <%
                        }
                    %>
                    <td><label>
                      <div align="left"><%= ac.getFullname() %></div>
                    </label></td>
                    </tr>

                    <tr>
                     <td><label>
                       <div align="justify">Date Join :</div>
                      </label></td>
                        <td><label>
                          <div align="left"><%= date %></div>
                        </label></td>
                    </tr>
					  <tr>
                     <td><label>
                       <div align="justify">School :</div>
                       </label></td>
                        <td><label>
                          <div align="left"><%= ac.getSchool() %></div>
                        </label></td>
                    </tr>
					<tr>
                     <td><label>
                       <div align="justify">Address :</div>
                      </label></td>
                        <td><label>
                          <div align="left"><%= ac.getAddress() %></div>
                        </label></td>
                    </tr>
                    <tr>
                        <td colspan="2" align="left"><a href="NamNHServlet?action=USVIEWEV">Manage Event</a></td>
                    </tr>
                    <tr>
                        <td colspan="2" align="left"><a href="PhuocPHServlet?action=USVIEWCOM">Manage Comment</a></td>
                    </tr>
                    <tr>
                         <td> <a href="UpdateProfile.jsp">Profile detail </a></td>
			 <td><input type="submit" name="action" value="Sign Out" class="Button"/></td>
		   </tr>
                </table>
                    </form>
<%
                }
%>
            <div class="cleaner"></div>

       </div><div class="sidebar_box_bottom"></div>

    	<div class="sidebar_box">
 <jsp:include flush="true" page="TopnewEvents.jsp"></jsp:include>
        </div><div class="sidebar_box_bottom"></div>

    </div>

    <div id="templatemo_content">

    	<div class="content_box">

            <h2>PROFILE</h2>
            <table class="table2" border="0">
            <form name="f3" action="UpdateProfileServlet" method="post" enctype="multipart/form-data" id="UpdateProfile">
<%
    Account acc = (Account)session.getAttribute("User_Session");
%>

                    <tr>
                        <td align="right">Username : </td>
                        <td align="left"><span class="style1"><%= acc.getUsername() %></span>
                            <input type="hidden" name="txtUser1" value="<%= acc.getUsername() %>"/>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">Password : </td>
                        <td align="left"><input type="password" name="txtPass1" value="<%= acc.getPassword() %>" class="inputt" id="txtPass"/>(<span class="style1">*</span>)<br/>
                        <label for="txtPass1" generated="true" class="error"></label></td>
                    </tr>
                    <tr>
                        <td align="right">Confirm Password : </td>
                        <td align="left"><input type="password" name="txtCfPass1" value="<%= acc.getPassword() %>" class="inputt" id="txtCfPass"/>(<span class="style1">*</span>)<br/>
                        <label for="txtCfPass1" generated="true" class="error"></label></td>
                    </tr>
                    <tr>
                        <td align="right">Fullname : </td>
                        <td align="left"><input type="text" name="txtFull1" value="<%= acc.getFullname() %>" class="inputt"/>(<span class="style1">*</span>)<br/>
                        <label for="txtFull1" generated="true" class="error"></label></td>
                    </tr>
                    <tr>
                        <td align="right">Email : </td>
                        <td align="left"><%= acc.getEmail() %></td>
                    </tr>
                    <tr>
                        <td align="right">Gender : </td>
                        <td align="left"><%= acc.getGender() %></td>
                    </tr>
                    <tr>
                        <td align="right" valign="top">Address : </td>
                        <td align="left"><textarea name="txtAdd1"><%= acc.getAddress() %></textarea>(<span class="style1">*</span>)<br/>
                        <label for="txtAdd1" generated="true" class="error"></label></td>
                    </tr>
                    <tr>
                        <td align="right">Phone : </td>
                        <td align="left"><input type="text" name="txtPhone1" value="<%= acc.getPhone() %>" class="inputt"/>(<span class="style1">*</span>)<br/>
                        <label for="txtPhone1" generated="true" class="error"></label></td>
                    </tr>
                    <tr>
                        <td align="right">School : </td>
                        <td align="left"><input type="text" name="txtSchool1" value="<%= acc.getSchool() %>" class="inputt"/>(<span class="style1">*</span>)<br/>
                        <label for="txtSchool1" generated="true" class="error"></label></td>
                    </tr>
                    <tr>
                        <td align="right">Birthday : </td>
                        <td align="left"><%= acc.getBirthday() %></td>
                    </tr>
                    <tr>
                        <td align="right" valign="top">Avatar : </td>
                        <td align="left">
<%
        if(acc.getAvatar()==null)
            {
%>
                            <img class="avatar" src="images/avatar/avatar.jpg" width="100" height="100"/><br/>
<%
        }else{

%>
                            <img class="avatar" src="images/avatar/<%= acc.getAvatar() %>" width="100" height="100"/><br/>
<%
               }
%>
                            <input type="file" name="fileAvatar1" accept="fileupload/*" size="25"/>(<span class="style1">*</span>)<br/>
                        <label for="fileAvatar1" generated="true" class="error"></label></td>
                    </tr>
                    <tr>
                        <td></td>
                        <td align="left">
                            <input type="submit" name="action" value="Save" class="Button"/>
                            <input type="reset" name="action" value="Reset" class="Button"/>
                        </td>
                    </tr>
                
            </form>
            </table>
<script type="text/javascript">
    jQuery(document).ready(function($) {
           $("#UpdateProfile").validate({
             messages: {
                 txtPass1: {
                     required: "Password is required",
                     rangelength: "Password must be 6 to 20 characters"
                 },
                 txtCfPass1: {
                     required: "Password Confirm is required",
                     equalTo: "Please enter the same value with Password",
                     rangelength: "Password Confirm must be 6 to 20 characters"
                 },
                 txtFull1: {
                     required: "Full Name is required",
                     rangelength: "Full Name must be from 5 to 30 characters"
                 },
                  txtPhone1: {
                     required: "Phone is required",
                     digits:"Please enter only Number" ,
                     rangelength: "Phone must be from 9 to 11 characters"
                 },
                 txtAdd1:{
                     required: "Address is required",
                     rangelength: "Address must be from 5 to 50 characters"
                 },
                 txtSchool1:{
                     required: "School is required",
                     rangelength: "School must be from 5 to 50 characters"
                 },
                 fileAvatar1: {
                     accept:"Avatar only accept file jpg,png,gif"
                 }
            },
            rules: {
                txtPass1: {
                    required: true,
                    rangelength: [6, 20]
                },
                txtCfPass1: {
                    required: true,
                    equalTo: "#txtPass",
                    rangelength: [6, 20]
                },
                txtFull1: {
                    required: true,
                    rangelength: [5, 30]
                },
                 txtPhone1: {
                    required: true,
                    digits: true,
                    rangelength: [9, 11]
                },
                txtAdd1:{
                    required: true,
                    rangelength: [5, 50]
                },
                txtSchool1:{
                    required: true,
                    rangelength: [5, 50]
                },
                fileAvatar1: {
                    accept:'jpg|gif|png'
                }
            }
        });
    });
         $(".cancel").click(function() {
		validator.resetForm();
	});

 </script>
        	<div class="cleaner"></div>
        </div><div class="content_box_bottom"></div>

        <div class="content_box">

        	<h2>Testimonial</h2>

            <div class="section_w250 float_l">
				<h3>Praesent sollicitudin</h3>
				<p>Nullam faucibus volutpat sapien sit amet tristique. Suspendisse venenatis, urna nec rhoncus suscipit, turpis turpis auctor nisi.</p>

            </div>

            <div class="section_w250 float_r">
				<h3>Quisque blandit</h3>
				<p>Morbi blandit ipsum sed purus vestibulum bibendum. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed nec nibh sed tellus.</p>

            </div>


        	<div class="cleaner"></div>
        </div><div class="content_box_bottom"></div>

    </div>

    <div class="cleaner"></div>

</div>

<!---------------------------------End Content ------------------------>

<div id="templatemo_footer_wrapper">

    <jsp:include page="footer.jsp" flush="true"/>

</div>
</body>
</html>
<%
}
%>